package com.lanyou.cook.camel.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读properties文件
 * @author ly-lihailang
 *
 */
public class PropFactory {
	private static Properties prop;
	//创建Properties实例并将文件读入
	static {
		prop = new Properties();
		InputStream in;
		try {
			in = new FileInputStream("./deploy/camelFtp.properties");
			prop.load(in);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * @param key 读取properties文件的key
	 * @return 根据key返回文件对应的值
	 */
	public static String getPropByKey(String key) {
		return prop.getProperty(key);
	}

	/**
	 * @return 已读入文件内容的Properties实例
	 */
	public static Properties getProperties() {
		return prop;
	}
}
